#include <iostream>
#include <string>
#include "39OOP-usingClass.hpp"

using namespace std;

int main(int argc, char const *argv[])
{
    {
        cout << "Using constructors to create new objects\n";
        DefineAClass nanoSmart = DefineAClass("NanoSmart", 12, 20.0);
        nanoSmart.show();
        DefineAClass boffo("Boffo Objects", 2, 2.0);
        boffo.show();

        cout << "Assigning nanoSmart to boffo" << endl;
        nanoSmart = boffo;
        cout << "Listening nanoSmart and boffo" << endl;
        nanoSmart.show();
        boffo.show();

        cout << "Using a constructor to reset an object" << endl;
        nanoSmart = DefineAClass("Nifty Foods", 10, 50.0); // temp object
        cout << "Revised nanoSmart: " << endl;
        nanoSmart.show();
        cout << "Done!" << endl;
    }
    // 这里多了大括号的说明: 假设没有{},可能执行完return 0之后执行析构函数,所以这里使用一个大括号声明一个作用域,保证在执行完析构函数后执行return 0;
    return 0;
}

// g++ -Wall -g .\42improveDefineAClass_main.cpp .\42improveDefineAClass.cpp .\39OOP-usingClass.hpp -o .\42improveDefineAClass_main.exe

/*
    Using constructors to create new objects
    Constructor using NanoSmart called
    Company: NanoSmart  Shares: 12
      Share Price: $20.000  Total Worth: $240.000
    Constructor using Boffo Objects called
    Company: Boffo Objects  Shares: 2
      Share Price: $2.000  Total Worth: $4.000
    Assigning nanoSmart to boffo
    Listening nanoSmart and boffo
    Company: Boffo Objects  Shares: 2
      Share Price: $2.000  Total Worth: $4.000
    Company: Boffo Objects  Shares: 2
      Share Price: $2.000  Total Worth: $4.000
    Using a constructor to reset an object
    Constructor using Nifty Foods called
    Bye, Nifty Foods !
    Revised nanoSmart:
    Company: Nifty Foods  Shares: 10
      Share Price: $50.000  Total Worth: $500.000
    Done!
    Bye, Boffo Objects !
    Bye, Nifty Foods !
*/
